package main

import (
	"fmt"
	"os"
)

func main() {
	//返回文件指针，参数为地址(绝对目录/相对目录)
	file, err := os.Create("../file/20211028.vim")
	if err != nil {
		fmt.Println("create file faild,err:", err)
		return
	}
	defer file.Close()
	fmt.Println("create file success")

	f, err := os.Open("../file/20211028.vim")

	if err != nil {
		fmt.Println("open file faild,err:", err)
		return
	}
	//往文件写数据
	_, err = f.WriteString("tody  tired") //因为文件只读，所以报错

	if err != nil {
		fmt.Println("writeSting file faild,err:", err)
		return
	}
	fmt.Println("writeSting file success")
	defer f.Close()
}
